﻿cmake_minimum_required(VERSION 3.5)
project(QtClient VERSION 0.1 LANGUAGES CXX)

# 设置Qt相关的自动处理
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

# 查找Qt库
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets)

# 定义项目源文件
set(PROJECT_SOURCES
    main.cpp
    mainwindow.cpp
    mainwindow.ui
    dialoglogin.cpp
    dialoglogin.ui
    dialoginiprogram.cpp
    dialoginiprogram.ui
    Business/inputhandler.cpp
    Business/businessinit.cpp
    Business/businessnetwork.cpp
    Business/businessuser.cpp
    Business/businessmsghandler.cpp
    Network/network.cpp
    res.qrc
    Business/businessviewmodel.cpp
    userlistwidget.cpp
    chatwindow.cpp
    chatwindow.ui
    bubblelist.cpp
    bubble.cpp
    bubble.ui
    Business/businesschat.cpp
    Business/businessfile.cpp
    friendrequestlist.cpp
    friendrequestlist.ui
    Business/businessgroup.cpp
    grouprequestlist.cpp
    grouprequestlist.ui
    Business/businesssql.cpp
    avatarselector.cpp
    avatarselector.ui
)

set(PROJECT_HEADERS
    mainwindow.h
    dialoglogin.h
    dialoginiprogram.h
    Business/inputhandler.h
    Business/businessinit.h
    Business/businessnetwork.h
    Business/businessuser.h
    Business/businessmsghandler.h
    Network/network.h
    Business/businessviewmodel.h
    userlistwidget.h
    chatwindow.h
    bubblelist.h
    bubble.h
    Business/businesschat.h
    Business/businessfile.h
    friendrequestlist.h
    Business/businessgroup.h
    grouprequestlist.h
    Business/businesssql.h
    avatarselector.h
)


# 创建可执行文件
include_directories(../common)

find_package(libhv CONFIG REQUIRED)

qt_add_executable(client
    ${PROJECT_SOURCES}
    ${PROJECT_HEADERS}
    MANUAL_FINALIZATION
)

# 链接Qt库和common库
target_link_libraries(client PRIVATE Qt${QT_VERSION_MAJOR}::Widgets common)
target_link_libraries(client PRIVATE hv)

set_target_properties(client PROPERTIES
    ${BUNDLE_ID_OPTION}
    MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
    MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
    MACOSX_BUNDLE TRUE
    WIN32_EXECUTABLE TRUE
)

qt_finalize_executable(client)
